1 ========================================================================
2 CSASPNETHTMLEditorExtender Overview
3 ========================================================================
5 /////////////////////////////////////////////////////////////////////////////
8 The project illustrates how to add a custom button to the toolbar of a
9 HTMLEditor in the Ajax Control Toolkit 4.1.40412.0.
11 /////////////////////////////////////////////////////////////////////////////
14 Please follow these demonstration steps below.
16 Step 1: Open the CSASPNETHTMLEditorExtender.sln.
18 Step 2: [This step is very important!]Rebuild the solution.
20 Step 3: Expand the TestWebSite and right-click the Default.aspx
21 and click "View in Browser".
23 Step 4: Input some text into the Editor.
25 Step 5: Select some text from your input.
27 Step 6: Click the last "H1" button form the top toolbar.
29 Step 7: You will see the selected text has been formatted to the style of H1.
30 If you click the second button from the bottom toolbar, you will see
31 that the selected text has been surrounded with tag <H1>.
33 /////////////////////////////////////////////////////////////////////////////
36 Step 1: Download the AjaxControlToolkit from this link:
37 http://www.asp.net/ajaxlibrary/act.ashx
39 Step 2. Create a C# "Class Library" project in Visual Studio 2010 or
40 Visual Web Developer 2010. Change the name to HTMLEditorExtender.
42 Step 3. Add references in the list below:
43 AjaxControlToolkit (version 4.1.40412.0)
47 Step 4. Create two new folders, call them Images and ToolBar_buttons.
49 Step 5. we need two icons for the button, one for the actived button and one
50 for the un-actived button. I create two images,
51 one called ed_format_h1_a.gif and another is ed_format_h1_n.gif.
52 Add the two images into the folder Images.
54 Step 6. Select the two images in the Solution Explorer of the VS.
55 Right-click them and select Properties.
56 You can find Build Action,
57 set the Build Action to Embedded Resource.
60 Step 7. In the folder ToolBar_buttons, create a js file, I named it H1.pre.js.
62 Step 8. Write the JavaScript functions in H1.pre.js to register
63 the client features for the H1 button. We can get the full functions in
64 the sample file H1.pre.js.
66 Step 9. Do the same thing in Step 5, make the Build Action to Embedded Resource
69 Step 10. Create a new class file, I call it H1.cs, in the ToolBar_buttons folder.
71 Step 11. Write the codes to register server side class for the button. Refer to
74 Step 12. Create a new class in the root of the project, I call it MyEditor.cs.
75 Write the code like below to make an extender Editor.
77 namespace HTMLEditorExtender
79 public class MyEditor : Editor
81 protected override void FillTopToolbar()
83 base.FillTopToolbar();
84 TopToolbar.Buttons.Add(new H1());
90 Step 13. Build the project.
92 Step 14. Create a new C# "Web Site", change the last folder name to TestWebSite.
94 Step 15. Add reference of the class project, HTMLEditorExtender.
96 Step 16. Create a test page. And add two Register declaration like below.
98 <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
99 <%@ Register Assembly="HTMLEditorExtender" Namespace="HTMLEditorExtender" TagPrefix="asp" %>
102 Step 17. Create a ToolScriptManager and a MyEditor to the page.
104 <asp:ToolkitScriptManager runat="server" ID="ToolkitScriptManager1"></asp:ToolkitScriptManager>
105 <asp:MyEditor runat="server" ID="MyEditor1" />
108 Step 18. Test the Default.aspx.
110 /////////////////////////////////////////////////////////////////////////////
114 http://www.asp.net/ajaxlibrary/act_HTMLEditor.ashx